Skip to content

Comments

False Positive on Match Arm Comparison with Incremented Bounded Integer#5003

Merged
VincentLanglet merged 4 commits intophpstan:2.1.xfrom
VincentLanglet:fix/11310
Feb 21, 2026
Merged

False Positive on Match Arm Comparison with Incremented Bounded Integer#5003
VincentLanglet merged 4 commits intophpstan:2.1.xfrom
VincentLanglet:fix/11310

Conversation

@VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Feb 19, 2026

Inspired from #4968

Closes phpstan/phpstan#11310

phpstan-bot and others added 2 commits February 19, 2026 20:06
- MutatingScope::enterMatch() re-evaluated the condition type after the
  scope had already been updated by processing the increment expression,
  causing $i++ to be seen as int<1, max> instead of int<0, max>
- Pass the pre-computed condition type and native type from
  NodeScopeResolver to enterMatch() so it uses the correct types
- New regression test in tests/PHPStan/Rules/Comparison/data/bug-11310.php

Closes phpstan/phpstan#11310
Automated fix attempt 1 for CI failures.
@VincentLanglet VincentLanglet marked this pull request as ready for review February 19, 2026 20:01
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@VincentLanglet VincentLanglet merged commit 03e0417 into phpstan:2.1.x Feb 21, 2026
640 of 645 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants